import http from '@/util/http.js';


//获取字典数据
export function dictionaryList(pagination, param) {
    let url = `/sys/dictionary/list/${pagination.pageSize}/${pagination.current}`;
    return new Promise((resolve, reject) => {
        http.get(url, param).then(response => {
            resolve(response)
        });
    });
}

//添加字典
export function dictionaryAdd(param) {
    let url = `/sys/dictionary/add`;
    return new Promise((resolve, reject) => {
        http.post(url, param).then(response => {
            resolve(response)
        })
    });
}


//根据ID修改字典
export function dictionaryUpdate(id, param) {
    let url = `/sys/dictionary/update/${id}`;


    return new Promise((resolve, reject) => {
        http.put(url, param).then(response => {
            resolve(response)
        })
    });
}

//根据ID字典数据
export function dictionaryDel(id) {
    let url = `/sys/dictionary/delete/${id}`;
    return new Promise((resolve, reject) => {
        http.delete(url).then(response => {
            resolve(response)
        })
    });
}

//获取字典明细列表
export function dictionaryMxList(pagination, param) {
    let url = `/sys/dictionary/mx/list/${pagination.pageSize}/${pagination.current}`;
    return new Promise((resolve, reject) => {
        http.get(url, param).then(response => {
            resolve(response)
        });
    });
}

//添加字典明细
export function dictionaryMxAdd(param) {
    let url = `/sys/dictionary/mx/add`;
    return new Promise((resolve, reject) => {
        http.post(url, param).then(response => {
            resolve(response)
        })
    });
}


//根据id修改字典选项
export function dictionaryMxUpdate(id, param) {
    let url = `/sys/dictionary/mx/update/${id}`;
    return new Promise((resolve, reject) => {
        http.put(url, param).then(response => {
            resolve(response)
        })
    });
}


//删除字典
export function dictionaryMxDel(id) {
    let url = `/sys/dictionary/mx/delete/${id}`;
    return new Promise((resolve, reject) => {
        http.delete(url).then(response => {
            resolve(response)
        })
    });
}


//获取菜单路由树
export function getMenuTree(param) {
    let url = `/sys/menu/tree`;
    return new Promise((resolve, reject) => {
        http.get(url, param).then(response => {
            resolve(response)
        });
    });
}


//添加菜单路由
export function menuAdd(param) {
    let url = `/sys/menu/add`;
    return new Promise((resolve, reject) => {
        http.post(url, param).then(response => {
            resolve(response)
        })
    });
};


//根据id修改菜单
export function menuUpdate(id, param) {
    let url = `/sys/menu/update/${id}`;
    return new Promise((resolve, reject) => {
        http.put(url, param).then(response => {
            resolve(response)
        })
    });
}


//根据ID删除菜单
export function menuDel(id) {

    let url = `/sys/menu/delete/${id}`;
    return new Promise((resolve, reject) => {
        http.delete(url).then(response => {
            resolve(response)
        });
    });
};


//获取错误码列表
export function getErrorList(pagination, param) {
    let url = `/sys/error/list/${pagination.pageSize}/${pagination.current}`;
    return new Promise((resolve, reject) => {
        http.get(url, param).then(response => {
            resolve(response)
        });
    });
}


//添加错误码
export function errorAdd(param) {
    let url = `/sys/error/add`;
    return new Promise((resolve, reject) => {
        http.post(url, param).then(response => {
            resolve(response)
        });
    });
};


//根据错误码ID修改错误码
export function errorUpdate(id, param) {
    let url = `/sys/error/update/${id}`;
    return new Promise((resolve, reject) => {
        http.put(url, param).then(response => {
            resolve(response)
        })
    });
}


//根据错误码ID删除错误码
export function errorDel(id) {
    let url = `/sys/error/delete/${id}`;
    return new Promise((resolve, reject) => {
        http.delete(url).then(response => {
            resolve(response)
        });
    });
};




//获取日志列表
export function getLogList(pagination, param) {
    let url = `/sys/log/list/${pagination.pageSize}/${pagination.current}`;
    return new Promise((resolve, reject) => {
        http.get(url, param).then(response => {
            resolve(response)
        });
    });
}


//=====================================================参数模块=========================

//获取模块列表
export function getModuleList() {
    let url = `/sys/param/list`;
    return new Promise((resolve, reject) => {
        http.get(url).then(response => {
            resolve(response)
        });
    });
}


//获取模块列表
export function removeModule(id) {
    let url = `/sys/param/delete/${id}`;
    return new Promise((resolve, reject) => {
        http.delete(url).then(response => {
            resolve(response)
        });
    });
}



//添加模块

export function moduleAdd(data) {
    let url = `/sys/param/add`;
    return new Promise((resolve, reject) => {
        http.post(url, data).then(response => {
            resolve(response)
        });
    });
}


export function moduleUpdate(id, data) {
    let url = `/sys/param/update/${id}`;
    return new Promise((resolve, reject) => {
        http.put(url, data).then(response => {
            resolve(response)
        });
    });
}





//根据模块代码获取参数配置项
export function getParamItemList(moduleCode) {
    let url = `/sys/param/item/list/${moduleCode}`;
    return new Promise((resolve, reject) => {
        http.get(url).then(response => {
            resolve(response)
        });
    });
}








export function paramItemAdd(data) {
    let url = `/sys/param/item/add`;
    return new Promise((resolve, reject) => {
        http.post(url, data).then(response => {
            resolve(response)
        });
    });
}


export function paramItemUpdate(id, data) {
    let url = `/sys/param/item/update/${id}`;
    return new Promise((resolve, reject) => {
        http.put(url, data).then(response => {
            resolve(response)
        });
    });
}


export function paramItemDelete(id) {
    let url = `/sys/param/item/delete/${id}`;
    return new Promise((resolve, reject) => {
        http.delete(url).then(response => {
            resolve(response)
        });
    });
}
